package com.probiz.estore.sales.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import com.probiz.estore.common.model.sales.GiftCertificate;
import com.probiz.estore.core.search.SearchCriteria;
import com.probiz.estore.core.service.GenericManager;
import com.probiz.estore.exception.GiftCertificateStateException;
import com.probiz.estore.sales.model.GiftCertificateSearchCriteria;


public interface GiftCertificateManager extends GenericManager<GiftCertificate>
{
	/**
	 * 根据礼券号码获得礼券实体
	 * @param giftCertificateNo
	 * @return
	 */
    public GiftCertificate getGiftCertificate(String giftCertificateNo);
    /**
     * 发送礼券给用户
     * @param gc
     * @param orderNo
     */
    public void sendGiftCertificate(GiftCertificate gc, String orderNo);
    /**
     * 后台搜索礼券
     * @param _searchCriteria
     * @param _giftCertificateSearchCriteria
     * @return
     */
    public List<GiftCertificate>  searchGiftCertificates(SearchCriteria _searchCriteria, GiftCertificateSearchCriteria _giftCertificateSearchCriteria);
    /**
     * 订单创建礼券
     * @param giftCertificate
     * @return
     */
    public GiftCertificate createGiftCertificate4Order(GiftCertificate giftCertificate);
    /**
     * 管理员手工创建礼券
     * @param giftCertificate
     * @return
     */
    public GiftCertificate createGiftCertificate4Admin(GiftCertificate giftCertificate);
    
    

	/**
	 * 检查礼券是否可用
	 * 
	 * @param giftCertificateNo
	 *            礼券编号
	 * @throws GiftCertificateStateException 
	 * 
	 * GiftCertificateStateException会有两个成员变量
	 * giftCertificateNo  是抛出异常的礼券号码
	 * state 是抛出异常对应的错误码 GiftCertificate.STATE_INVALID //无效,礼券号不存在或者其他原因
	 *         					GiftCertificate.STATE_UNACTIVE //无效，因为礼券号未激活
	 *         					GiftCertificate.STATE_UNDEAL //无效，因为礼券号在交易中，暂时不能使用
	 *         					GiftCertificate.STATE_EXPIRE //无效，因为礼券号已经超过可用时间
	 *         					GiftCertificate.STATE_NOT_ENOUGH_REMAINEDAMT //无效，因为余额不足以支付规定的金额 (这个错误状态是最主要的)
	 */
	public void checkGiftcertificate(String giftCertificateNo) throws GiftCertificateStateException;
	
    /**
	 * 使用礼券支付，下订单时调用的
	 * @param giftCertificateNo 礼券号码
	 * @param decMoney 要扣除的金额
	 * @param orderNo 使用的订单号码
	 * @throws GiftCertificateStateException 
	 * 
	 * GiftCertificateStateException会有两个成员变量
	 * giftCertificateNo  是抛出异常的礼券号码
	 * state 是抛出异常对应的错误码 GiftCertificate.STATE_INVALID //无效,礼券号不存在或者其他原因
	 *         					GiftCertificate.STATE_UNACTIVE //无效，因为礼券号未激活
	 *         					GiftCertificate.STATE_UNDEAL //无效，因为礼券号在交易中，暂时不能使用
	 *         					GiftCertificate.STATE_EXPIRE //无效，因为礼券号已经超过可用时间
	 *         					GiftCertificate.STATE_NOT_ENOUGH_REMAINEDAMT //无效，因为余额不足以支付规定的金额 (这个错误状态是最主要的)
	 */
    public void doUseGiftCertificate(String giftCertificateNo, BigDecimal decMoney,String orderNo) throws GiftCertificateStateException;
    
    /**
     * 订单完成时候将礼券变成可交易状态
     * @param giftCertificateNo
     * @param decMoney
     * @param orderNo
     * @throws GiftCertificateStateException
     */
    public void doCompleteUseGiftCertificate(String giftCertificateNo, BigDecimal decMoney,String orderNo) throws GiftCertificateStateException; 
    
    /**
     * 订单取消返还支付了的礼券金额
     * @param giftCertificateNo
     * @param decMoney
     * @throws GiftCertificateStateException
     */
    public void doReturnGiftCertificate(String giftCertificateNo, BigDecimal decMoney) ;
}
